{include file="public_head" /}
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">
<!-- chk_3 -->
<link href="__STATIC__/css/chk_3.css" rel="stylesheet" type="text/css"/>
<!-- Select2 -->
<link href="__STATIC__/css/select/select2.min.css" rel="stylesheet">

<body class="nav-md">

<div class="container body">


    <div class="main_container">

        {include file="public_sidebar,public_nav" /}

        <!-- page content -->
        <div class="right_col" role="main">
            <div class="">
                <div class="page-title">
                    <div class="title_left">
                        <h3>
                            发放会员卡记录
                        </h3>
                    </div>
                </div>
                <div class="clearfix"></div>

                <div class="row">
                    <div class="col-md-12 col-sm-12 col-xs-12">
                        <div class="x_panel">
                            <div class="x_title">

                                <a style="float: right" href="{:url('create')}"
                                   class="btn btn-success btn-sm">发放会员卡</a>
                                <div class="clearfix"></div>
                            </div>
                            <div class="x_content"><form name="form" id="form" method="get" action="">
                                <div class="title_left">

                                    <div class="input-group" style="float: left;margin: 0 20px;">

                                        <select name="shop_id" id="status1" class="select2_single1" style="width: 200px;"
                                                tabindex="-1">
                                            <option value="0">- 全部门店 -</option>
                                            {volist name="$shop_list" id="item"}
                                            <option value="{$item.id}" {eq name=':input("shop_id")' value='$item.id' }selected{/eq}>{$item.shop_title}</option>
                                            {/volist}
                                        </select>

                                    </div>
                                    <div class="input-group" style="float: left;margin: 0 20px;">
                                        <input type="text" class="form-control" name="interval_timer"
                                               id="interval_timer"
                                               style="width: 200px;"
                                               placeholder="请选择时间区间..." value="{:input('interval_timer')}">
                                    </div>
                                    <div class="col-md-2 col-sm-3 col-xs-12 form-group pull-left top_search">

                                        <div class="input-group">
                                            <input type="text" class="form-control" name="title"
                                                   placeholder="输入用户名称..." value="{:input('title')}">
                                        </div>

                                    </div>

                                    <button type="submit" class="btn btn-primary" style="margin-left: 10px;">搜 索</button>
                                </div>


                            <table class="table table-striped table-bordered">
                                <thead>
                                <tr class="success">
                                    <td>
                                        ID
                                    </td>
                                    <th>会员卡用户</th>
                                    <th>车牌号</th>
                                    <th>发放门店</th>
                                    <th>会员卡类型</th>
                                    <th>总次数-剩余次数</th>
                                    <th>开始时间 / 结束时间</th>
                                    <th>发放时间</th>
                                    {eq name=":session('role_id')" value="1"}
                                    <th>操作</th>
                                    {/eq}
                                </tr>
                                </thead>
                                <tbody>
                                {empty name="data"}
                                <tr><td colspan="9"><div style='font-size:24px;margin:30px 0;'>没有找到记录</div></td></tr>
                                {/empty}
                                {volist name="data" id="item"}
                                <tr>
                                    <td>{$item.id}</td>
                                    <td>{neq name=":session('role_id')" value="1"}
                                        {:hideStr($item.username,1,6)}
                                        {else/}
                                        {$item.username}
                                        {/neq}
                                    </td>
                                    <td>{$item.car_number}</td>
                                    <td>{empty name="$item.shop_title"}
                                        <a href="{:url('gift_order/update',['id' => $item.order_id])}" >线上购买</a>
                                        {else/}
                                        <a href="{:url('gift_order/update',['id' => $item.order_id])}" >
                                        {$item.shop_title}
                                        </a>
                                        {/empty}
                                    </td>
                                    <td>
                                        {switch name="$item.type"}
                                        {case 1}年卡{/case}
                                        {case 2}次卡{/case}
                                        {/switch}
                                    </td>
                                    <td>
                                        {switch name="$item.count"}
                                        {case 10000}无限{/case}
                                        {default /}{$item.zcs}({$item.sycs})
                                        {/switch}
                                    </td>

                                    <td>
                                        {$item.start_time} 至 {$item.end_time}
                                    </td>
                                    <td>{$item.create_time}</td>
                                    {eq name=":session('role_id')" value="1"}
                                    <td class="operate">
                                        <div>
                                            <!--<a href="{:url('update', ['id' => $item['id']])}"-->
                                               <!--class="label label-primary">-->
                                                <!--<span class="fa fa-pencil"></span>&nbsp;&nbsp;编 辑-->
                                            <!--</a>-->
                                            <!--<a href="{:url('index',['coupon_id'=>$item['id']])}"-->
                                               <!--class="label label-info">-->
                                                <!--<span class="fa fa-pencil"></span>&nbsp;&nbsp;查 看-->
                                            <!--</a>-->

                                            <a href="{:url('destroy', ['id' => $item['id']])}"
                                               class="label label-danger"
                                               onClick="return confirm('确定删除吗?')"
                                            >
                                                <span class="fa fa-times"></span>&nbsp;&nbsp;删 除
                                            </a>

                                        </div>
                                    </td>
                                    {/eq}
                                </tr>
                                {/volist}
                                </tbody>
                                <tbody align="left">
                                </tbody>
                            </table>
                            <!-- 分页 -->
                            <div style="float: right;margin-top: -30px;">{$data->render()}</div>
                                    <button type="button" class="btn btn-success" style="margin-top: 20px;" onclick="dcd()">用户会员卡导出</button>
                                <button type="button" class="btn btn-danger" style="margin-top: 20px;" onclick="dcd()">已发放会员卡总数 ( {$count} ) 个</button>
                            </form>
                        </div>
                    </div>
                </div>

            </div>
        </div>

    </div>
    <!-- /page content -->
</div>

</div>
</body>
{include file="public_foot" /}
<!-- public -->
<script src="__STATIC__/js/public.js"></script>
<!-- layer -->
<script src="__STATIC__/js/layer.js"></script>
<!--select-->
<script src="__STATIC__/js/select/select2.full.min.js"></script>
<script>
    // validform
    $(function () {

        // select2
        $(".select2_single1").select2({
            placeholder: "请选择分类",
            allowClear: true
        });
        $('#interval_timer').daterangepicker(null,
            function(start, end, label) {
//                console.log(start.toISOString(), end.toISOString(), label);
            });


    })
    //导出excel表格
    function dcd(){
        var both = $('#interval_timer').val();
        if(both == ''){
            //layer.msg('请选择时间区间');
            //return false;
        }
        var title = "{:input('title')}";
        var shop_id = "{:input('shop_id',0)}";
        window.location.href = "{:url('daochu')}?title="+title+'&shop_id='+shop_id+'&interval_timer=' + both;
    }
</script>